package com.bw.controller;

import com.bw.entity.Bing;
import com.bw.entity.Dict;
import com.bw.mapper.BingMapper;
import org.spring.kun.common.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class BingController {

    @Autowired
    BingMapper bingMapper;

    @RequestMapping("/tu.do")
    public String tu(Model model){

       List<Dict> sourceList =  bingMapper.listSource();
        model.addAttribute("sourceList",sourceList);
        return "tu";
    }

    @RequestMapping("/bing.do")
    @ResponseBody  // 返回JSON格式的数据
    public List<Bing> bing(Integer source,String status){

       List<Bing> list =  bingMapper.bing(source,status);

       return list;
    }

    @RequestMapping("/excel.do")
    public void excel(Integer source, String status, HttpServletResponse response){

       List<Bing> list =  bingMapper.bing(source,status);

        ExcelUtils.exportExcel(list,"人才信息统计表","sheet1",response);
    }
}
